#!/usr/bin/env node

const program = require("commander");
const minimist = require("minimist");

const cache = require("./src/util/cache");

const run = (url) => {
    return () => {
        cache.init();
        const args = process.argv.slice(3);
        require(url)(args);
    }
}

program
    .command("add [name[,name]]")
    .description("add new component")
    .action(run("./src/add"));

program
    .command("start [port]")
    .description("start open GUI page")
    .action(run("./src/start"));

program
    .command("build [name]")
    .option("-m,--minify", "minify file")
    .description("build components")
    .action(run("./src/build"));

program
    .command("lint [name[,name]]")
    .alias("l")
    .option("-e, --eslint <config-name>", "eslint plugin config")
    .option("-s, --stylelint", "stylelint verifying")
    .description("lint components")
    .action(run("./src/lint"));

program
    .command("test [name]")
    .option("-h,--headless", "open headless mode")
    .description("test components")
    .action(run("./src/test"));

program.parse(process.argv);